﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Winowajca
{
    public partial class AddWine : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        protected void btnAddWine_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid)
            {
                return;
            }

            Wine wine = AddWine1.GetWine();
            if (wine == null)
            {
                return;
            }

            using (DatabaseContext ctx = new DatabaseContext())
            {
                ctx.AddToWine(wine);                
                ctx.SaveChanges();
            }

            Response.Redirect("~/Index.aspx");
        }
    }
}